import { mapGetters, createNamespacedHelpers } from 'vuex'
import { useActionMapper } from './useMapper'
import { checkType } from './index'

export function useActions(moduleName, mapper) {
  let mapperFn = mapGetters

  if (checkType(moduleName) === '[object String]' && moduleName.length > 0) {
    mapperFn = createNamespacedHelpers(moduleName).mapGetters
  }
  return useActionMapper(mapper, mapperFn)
}
